<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf8">
    <title>test</title>
  </head>
  <body>
    <h1>it works!</h1>
    <script type="text/javascript">
      var child_process = require('child_process');
      var fork = child_process.fork;
      var node_name = "node";
      if (process.platform == "win32"){
        node_name += ".exe";
      }

      var path = require('path');
      var fs = require('fs');
      var modulePath = path.join(fs.realpathSync('.'), 'fork_module.js');

      var child = fork(modulePath,[],{"execPath":node_name});
      var message = "hello world";
      var result = false;
      var gui = require('nw.gui');
      var port = gui.App.argv[0] || 13013;

      child.on("message",function(m){
        console.log(m);
        if (m == message){
          result = true;
        }

        var socket = require('net').connect({port: 13013});
        socket.setEncoding('utf8');
        socket.end(result.toString());
        setTimeout(function(){
            gui.App.quit();
        },200);


        });

      child.send(message);
      setTimeout(function(){
        gui.App.quit();
      },2000);
    </script>
  </body>
</html>
